#include "FaceDetector.h"

FaceDetector::FaceDetector() :
    minFaceSize(30, 30),
    maxFaceSize(300, 300) {
}

bool FaceDetector::loadCascade(const string& cascadePath) {
    return faceCascade.load(cascadePath);
}

vector<Rect> FaceDetector::detectFaces(const Mat& frame) {
    vector<Rect> faces;
    faceCascade.detectMultiScale(
        frame,
        faces,
        1.1,
        3,
        0 | CASCADE_SCALE_IMAGE,
        minFaceSize,
        maxFaceSize
    );
    return faces;
}

Mat FaceDetector::extractFace(const Mat& frame, const Rect& faceRect) {
    return frame(faceRect).clone();
}